package com.tjp.eight.ui.fragment.jifen.shareget;

import com.tjp.eight.AllRetrofit;
import com.tjp.eight.base.BasePresenterImpl;
import com.tjp.eight.constant.UrlConstant;
import com.tjp.eight.net.NetCallBack;
import com.tjp.eight.net.SubscribeCallBack;
import com.tjp.eight.utils.AppUtils;

import okhttp3.RequestBody;

/**
 * Created by Administrator on 2017/2/28.
 */
public class ShareGetPresenter extends BasePresenterImpl<ShareGetView> {
    private ShareGetSerivce service = AllRetrofit.getRetrofit(UrlConstant.BaseUrl).create(ShareGetSerivce.class);
    public ShareGetPresenter(ShareGetView view) {
        attachView(view);
    }

    public void load(String pJson) {
        RequestBody body = AppUtils.getRequestBody(pJson);

        addSubscription(service.load(body), new SubscribeCallBack<>(new NetCallBack<SharegetRModel>() {
            @Override
            public void onSuccess(SharegetRModel model) {
                view.loadSuccess(model);
            }

            @Override
            public void onFails(int code, String msg) {
                view.fail(msg);
            }

            @Override
            public void onCompleted() {

            }
        }));
    }
}
